Avoid resizing mutation in subst-char-in-string, take two
authorMattias Engdegård <mattiase@acm.org>
Mon, 13 May 2024 08:44:05 +0000 (10:44 +0200)
committerMattias Engdegård <mattiase@acm.org>
Mon, 13 May 2024 10:39:41 +0000 (12:39 +0200)
commit49e243c0c85d18fc775970d9ebd846eba3a6866e
tree2ee32a6f81bfe93b7d0f3f84d83ee82f655808d1
parent334fb0ddfe603097c3493297c3e78a185b22d1af
Avoid resizing mutation in subst-char-in-string, take two

This time we take care to preserve properties, and add a test.

* lisp/subr.el (subst-char-in-string):
Use string-replace to avoid resizing mutation and O(n^2) time.
* test/lisp/subr-tests.el (subr--subst-char-in-string): New test.
lisp/subr.el
test/lisp/subr-tests.el